<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/13 0013
 * Time: 下午 9:46
 */
namespace frontend\controllers;
use common\component\Constant;
use common\models\info\Category;
use common\utils\CommonUtil;
use frontend\component\FrontendBaseController;
use frontend\service\ArticleService;
use Yii;
use yii\web\Controller;
class CategoryController extends FrontendBaseController{
    public $layout = "/main";

    public function actionIndex(){
        $result = ArticleService::getDataType();
        $types = Category::findAll('');
        return $this->render('index',[
            'data' => $result,
            'types'=>$types
        ]);
    }
    public function actionDetail(){
            $get = \Yii::$app->request->get();
        $cate_id = $get['aid'];
          $page =isset($get['page'])?$get['page']:1;
          $rows =Category::getFieldById($cate_id);
        return $this->render('category',[
            'data' => ArticleService::getDataCate($cate_id,$page,10),
             'name'=>$rows,
            'page'=>$page,
            'pageSize'=>10,
            'url'=>'/category/'.$cate_id.'.html?page=',
            'breadcrumbs' => [
                [
                    'label'=> '文章分类',
                    'url'=>'/category.html'
                ],
                [
                    'label'=> $rows,
                    'url'=>CommonUtil::generateUrl($cate_id,Constant::ROUTE_CATEGORY)
                ],
            ]
        ]);

    }

}